<template>
	<scroll-view
		class="scroll-view"
		scroll-y
		:refresher-threshold="45"
		:refresher-enabled="true"
		:refresher-triggered="refresherTriggered"
		@refresherrefresh="refresherrefresh"
		@refresherrestore="refresherrestore"
		@refresherabort="refresherabort"
	>
		<slot></slot>
	</scroll-view>
</template>

<script>
export default {
	name: 's_list',
	data() {
		return {
			triggered: false,
			refresherTriggered: false,
			_refresherTriggered: false
		};
	},
	created() {
		// setTimeout(() => {
		// 	this.triggered = true
		// }, 1000);
	},
	methods: {
		// onRefresh() {
		// 	console.log(this._freshing)
		// 	if (this._freshing) return;
		// 	this.triggered = true;
		// 	this.$emit('onRefresh');
		// },
		// onRestore() {
		// 	console.log('aaaa');
		// 	this.triggered = 'restore'; // 需要重置
		// },
		afterload() {
			this.refresherTriggered = false; //触发onRestore，并关闭刷新图标
			this._refresherTriggered = false;
		},
		refresherrefresh() {
			console.log('自定义下拉刷新被触发');
			let _this = this;
			if (_this._refresherTriggered) {
				return;
			}
			_this._refresherTriggered = true;
			//界面下拉触发，triggered可能不是true，要设为true
			if (!_this.refresherTriggered) {
				_this.refresherTriggered = true;
			}
			this.$emit('onRefresh');
		},
		refresherrestore() {
			console.log('自定义下拉刷新被复位');
			let _this = this;
			_this.refresherTriggered = false;
			_this._refresherTriggered = false;
		},
		refresherabort() {
			console.log('自定义下拉刷新被中止	');
			let _this = this;
			_this.refresherTriggered = false;
			_this._refresherTriggered = false;
		},
	}
};
</script>

<style>
.scroll-view {
	height: 100%;
}
</style>
